package com.his.controller;

import com.his.pojo.CheckRequest;
import com.his.pojo.Prescription;
import com.his.service.PrescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class PrescriptionController {

    /*注入service*/
    @Autowired
    private PrescriptionService prescriptionService;

    /*处理处方信息保存的请求*/
    @PostMapping("/savePrescription")
    public Map<String,Object> savePrescription(@RequestBody List<Prescription> prescription){
        Map<String,Object> map=new HashMap<>();

        try{
            prescriptionService.saveBatch(prescription);
            map.put("msg","处方保存成功....");
            map.put("code",200);
        }catch (Exception ex){
            ex.printStackTrace();
            map.put("msg","处方保存失败.....");
            map.put("code",500);
        }
        return map;
    }
}
